package com.mxnavi5.example.DataStream;

import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;

import java.util.Random;

public class UdfSourceTest2 extends RichParallelSourceFunction {

    boolean running = true;
    int i =0;
    Random random = new Random();

    @Override
    public void run(SourceContext sourceContext) throws Exception {
        while (running){
            sourceContext.collect(random.nextInt(10));
            Thread.sleep(1000);
            if(i==20){
                Thread.sleep(10000);
            }
        }
    }

    @Override
    public void cancel() {
        running = false;
    }
}
